#pragma once

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN
#endif

#ifndef WINVER   
#define WINVER 0x0500  // Windows 2000 (required for accessibilties)
#endif

#ifndef _WIN32_WINNT  
#define _WIN32_WINNT 0x0500 // Windows 2000 (required for tooltips )
#endif  

#ifndef _WIN32_WINDOWS  
//#define _WIN32_WINDOWS 0x0410 // win98
#define _WIN32_WINDOWS 0x0400 
#endif

#ifndef _WIN32_IE   // IE Version
#define _WIN32_IE 0x0400
//#define _WIN32_IE 0x0500 // required for Tray-balloon-Tool-Tip
#endif


// MFC
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
#define _AFX_ALL_WARNINGS
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxtempl.h>
#include <afxdtctl.h> 
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif 
#include <afxdlgs.h>

#include <locale.h>


// STL
#include <vector>
#include <algorithm>

#include "string_util.h"



// pragma message helper
#define STRING2(x) #x
#define STRING(x) STRING2(x)


//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///  SETTINGS
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#include "patch_version.h"

#pragma message( "============================================================" )
#pragma message( __FILE__ "(" STRING(__LINE__) "): PATCH-Version " PATCH_VERSION " (EU: " PATCH_VERSION_EU ")" )
#pragma message( "============================================================" )


//////////////////////////////////////////////////////////////////////////

// Colors (for career mode)
#define COLOR_KEYSET  RGB(192,255,192)
#define COLOR_STATCHANGE RGB(0,128,0)

#ifdef RELEASE_DEBUG
    #define RELEASE_TRACE
#else
    #define TRACE_NO_CRASH_REPORT
#endif


#include "debug.h"

// LOG-Levels
#define LOG_BASE  0
#define LOG_DB   1
#define LOG_DB_DETAIL 2
#define LOG_PROFILE  3
#define LOG_DODATA  8




//////////////////////////////////////////////////////////////////////////
// Helpers
DWORD Hex2DWORD(const TCHAR*);
#define CLAMP(x,a,b) (x<a?a:(x>b?b:x))
bool ComboSelectByData(CComboBox*, DWORD_PTR);

#define NEG_WORD ((WORD)-1)
#define NEG_BYTE ((BYTE)-1)


#ifndef SAFE_FREE
#define SAFE_FREE( p )  if( p ){ free((void*)p); p = NULL; }
#endif

#ifndef SAFE_ZEROMEMORY
#define SAFE_ZEROMEMORY( p, size ) if( p ){ ZeroMemory( p, size ); }
#endif

#ifndef SAFE_RELEASE
#if defined( __cplusplus )
#define SAFE_RELEASE( p )  if( p ){ p->Release(); p = NULL; }
#else
#define SAFE_RELEASE( p )  if( p ){ p->lpVtbl->Release( p ); p = NULL; }
#endif
#endif

#ifndef  SAFE_COTASKMEMFREE
#define SAFE_COTASKMEMFREE( p ) if( p ){ CoTaskMemFree( (LPVOID)p ); p = NULL; }
#endif

#ifndef  _countof
#define _countof( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
#endif







// Visual Studio 2005 compatibility
#if _MSC_VER < 1400
#include "_secure_dummies_.h"
#endif


#include "dep/TinyXML/tinyxml.h"
#include "dep/CPPToolTip/PPToolTip.h"
#include "dep/Resizer/Resizer.h"

#include "CFileName.h"
#include "CDBInterfaceSQL.h"
#include "CAPage.h"
#include "CValueTable.h"
#include "CValueTableStr.h"
#include "CEditColor.h"
#include "Separator.h"
#include "ComboBoxSuper.h"



